<?php

require_once realpath('..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'bootstrap.php');
header('Content-Type: application/json');
$request = Bike_Service_Locator::getService('Request');
$login = $request->getPostVar('login');
$password = $request->getPostVar('password');
if(empty($login)){
	echo json_encode(array('success' => false, 'errors' => array('reason' => 'Please entet login')));
	die();
}

if(Bike_Service_Locator::getService('UserManager')->authenticate((string)$login, (string)$password)){
	echo json_encode(array('success' => true, 'errors' => array('reason' => 'Success')));
}else{
	echo json_encode(array('success' => false, 'errors' => array('reason' => 'Login and password do not match our records')));
}
